<template>
  <div id="AsnDetail">
    <div class="detail">
      <component
        :inputData="detailData"
        :is="currentComponent"
      ></component>
    </div>
  </div>

</template>

<script>
import detail from "commons/Detail";
import navMenu from "commons/NavMenu";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "Detail",
  mixins: [baseMixin],
  data () {
    return {
      newFlag: true,
      selectData: {},
      detailData: {},
      detailNav: "1",
      temporary: {},
      componentConfig: [
        {
          name: "particulars",
          label: "",
          component: () => import('./page/bhclQueryBt_form.vue')
        },
      ]
    }
  },
  computed: {
    currentComponent () {
      return this.componentConfig[this.detailNav - 1].component;
    }
  },
  methods: {
    async getData () {
      try {
        let key = encodeURI(encodeURI(this.selectData.strategycode))
        let res = await this.$api.get(`/queryRpstrategyByStrategycodeKey/${key}`);
        
          this.detailData = res.bean;
        
      } catch (e) {
        this.$message.error(e);
      }
    }
  },
  mounted () {
    this.newFlag = this.$store.state.newFlag;
    //判断是否事新建
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      this.detailData = data.detail;
      this.selectData = data.routeData;
      this.detailNav = data.detailNav;
    } else if (this.newFlag) {
      this.detailData = {
        strategycode: '',
        strategytype: '2',
        loctype1: 'OTHER',
        loctype2: 'OTHER',
        loctype3: 'OTHER',
        loctype4: 'OTHER',
        sorttype1: '1',
        sorttype2: '1',
        sorttype3: '1',
        sorttype4: '1',
        cubesort: '1',
        reqtype: '',
        pickarea: '',
        sortoption1: '',
        sortoption2: '',
        sortoption3: '',
        sortoption4: '',
        cancel: ''
      }
    } else {
      this.selectData = this.$store.state.routeData;
      this.getData();
    }

  },
  watch: {

  },
  components: {
    "v-detail": detail,
    "v-navMenu": navMenu,
  },

}
</script>

<style scoped>
</style>
